<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = [5,3,7,2,9,21,10]
        arr.sort(
            function(a,b){
                return a-b;
            }
        )
        // console.log(arr);
        var num = Number(prompt());
        for(i=0;i<arr.length;i++){
            if(num<=arr[i]){
                arr.splice(i,0,num)
                break;
            }else if(i==arr.length-1){
                arr.splice(i+1,0,num)
                break;
            }
        }
        console.log(arr);
    </script>
</body>
</html>